package icu.guodapeng.provider.service.impl

import com.alibaba.dubbo.config.annotation.Service
import icu.guodapeng.api.service.EchoService
import org.springframework.core.env.Environment
import org.springframework.stereotype.Component
import javax.annotation.Resource
import javax.ws.rs.Consumes
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.core.MediaType

@Service(protocol = ["rest"]) // 指定 rest 协议后，就不会启动其他协议的服务
@Path("/")
@Component
class EchoServiceImpl : EchoService {
    @Resource
    private lateinit var env: Environment

    @GET
    @Path("/echo/{param}")
    @Consumes(MediaType.APPLICATION_JSON)
    override fun echo(@PathParam("param") param: String) = "rest service: $param. mark: ${env.getProperty("mark")}"
}
